drop database if exists seata_order;
create database seata_order charset utf8;
use seata_order;

DROP TABLE IF EXISTS undo_log;
CREATE TABLE undo_log
(
    `branch_id`     bigint       NOT NULL COMMENT 'branch transaction id',
    `xid`           varchar(100) NOT NULL COMMENT 'global transaction id',
    `context`       varchar(128) NOT NULL COMMENT 'undo_log context,such as serialization',
    `rollback_info` longblob     NOT NULL COMMENT 'rollback info',
    `log_status`    int          NOT NULL COMMENT '0:normal status,1:defense status',
    `log_created`   datetime(6)  NOT NULL COMMENT 'create datetime',
    `log_modified`  datetime(6)  NOT NULL COMMENT 'modify datetime',
    UNIQUE KEY `ux_undo_log` (`xid`, `branch_id`)
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8mb3 COMMENT ='AT transaction mode undo table';


DROP TABLE IF EXISTS `tb_order`;
CREATE TABLE `tb_order`
(
    `id`         bigint NOT NULL,
    `user_id`    bigint         DEFAULT NULL COMMENT '用户id',
    `product_id` bigint         DEFAULT NULL COMMENT '产品id',
    `count`      int            DEFAULT NULL COMMENT '数量',
    `money`      decimal(11, 0) DEFAULT NULL COMMENT '金额',
    `status`     int            DEFAULT NULL COMMENT '状态',
    PRIMARY KEY (`id`)
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8mb3;

-- ----------------------------
-- Records of order
-- ----------------------------
BEGIN;
COMMIT;

SET FOREIGN_KEY_CHECKS = 1;